/*
 * @Author       : 邱狮杰
 * @Date         : 2021-07-09 13:03:28
 * @LastEditTime: 2021-07-09 23:15:18
 * @FilePath: /professional-work-decorator/src/property/value/defaultValue.ts
 * @Description  : default value
 */
type defaultValueCb<T> = () => T;
export function defaultVal<T>(val: T | defaultValueCb<T>): PropertyDecorator {
  return function (target: Object, key: string | symbol) {
    const desc: PropertyDescriptor = {
      writable: true,
      value: val,
    };
    return desc;
  };
}
